﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;

namespace OneCTest
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

        private void getCheckPointToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            DataTable tbl = new DataTable();
            Exception err = new Ko2.DB.OneC().GetCheckPoints(ref tbl);
            if (err == null)
                gv.DataSource = tbl;
        }

        private void getCheckPointDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataTable tbl = new DataTable();
            Exception err = new Ko2.DB.OneC().GetCheckPointsData(ref tbl, "Балашиха", 2011, 11);
            if (err == null)
                gv.DataSource = tbl;
        }

        private void returnsToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            DataTable tbl = new DataTable();
            DateTime dtNow = DateTime.Now;
            DateTime DTFrom = new DateTime(2011, 01,01);
            string Kontragent = "ЗДРВ";
            string Sklad = "Лесной городок брак";
            Exception err = new Ko2.DB.OneC().GetReturns(ref tbl, DTFrom, dtNow, Kontragent, Sklad);
            if (err == null)
                gv.DataSource = tbl;
        }

        private void returnsKontragentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataTable tbl = new DataTable();
            Exception err = new Ko2.DB.OneC().GetReturnsKontragent(ref tbl);
            if (err == null)
                gv.DataSource = tbl;
        }

        private void returnsSkladToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataTable tbl = new DataTable();
            Exception err = new Ko2.DB.OneC().GetReturnsSklad(ref tbl);
            if (err == null)
                gv.DataSource = tbl;
        }

        private void orgStructure_getXMLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Exception err = null;
            DataTable tbl = new DataTable();
            Ko2.DB.OneC o = new Ko2.DB.OneC();
            Ko2.Web.Utils.WS_Helper o2 = new Ko2.Web.Utils.WS_Helper();
            List<string> errList = new List<string>();
            err = o.GetOrgStructure(ref tbl, Ko2.DB.OneC.OrgStructure_Level_0_Names.Магазины);
            err = o2.GetOneC_OrgStructure(ref tbl, ref errList);
            if (err == null)
            {
                gv.DataSource = tbl;
                o.OrgStructure_FillTreeCtrl(ref tbl, ref ctrlTree);
                XmlDocument xDoc = new XmlDocument();
                o.OrgStructure_MakeXml(ref tbl, ref xDoc);
            }
        }


    }
}
